package com.zx.mes.disruptor.hyl.multihignconsumer;

import com.lmax.disruptor.WorkHandler;

import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * disruptor consumer
 *
 * @author huayunlong
 * @date 2018-9-13
 */
public class Consumer implements WorkHandler<Order> {


    public Consumer(String consumerId) {
        this.consumerId = consumerId;
    }


    private String consumerId;

    private Random random = new Random();

    private AtomicInteger count=new AtomicInteger(0);


    public AtomicInteger getCount() {
        return count;
    }

    public void setCount(AtomicInteger count) {
        this.count = count;
    }

    @Override
    public void onEvent(Order event) throws Exception {
        System.out.println("当前消费者:"+this.consumerId+"  消费信息id:"+event.getId());
        this.count.incrementAndGet();
    }
}
